package cn.zlj.pethome.user.controller;

import cn.zlj.pethome.basic.util.AjaxResult;
import cn.zlj.pethome.user.domain.User;
import cn.zlj.pethome.user.dto.EmailRegisterDto;
import cn.zlj.pethome.user.dto.PhoneRegisterDto;
import cn.zlj.pethome.user.service.RegisterDtoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
public class RegisterController {
    @Autowired
    private RegisterDtoService registerDtoService;

    @PostMapping("/phone")
    public AjaxResult phone(@RequestBody @Valid PhoneRegisterDto phoneRegisterDto){
             registerDtoService.register(phoneRegisterDto);
        return AjaxResult.me().success();
    }
    @PostMapping("/email")
    public AjaxResult email(@RequestBody @Valid EmailRegisterDto emailRegisterDto){
        registerDtoService.registerEmail(emailRegisterDto);
        return AjaxResult.me().success();
    }
}
